import re

#VlanId = 54, MacAddress = 0000-5e00-0136, Original-Port = GE0/0/1, Flapping port = GE0/0/2. 
#VlanId = (\d+), MacAddress = \S+, Original-Port = (\S+), Flapping port = (\S+)\. 
regex=(r'VlanId = (\d+), MacAddress = \S+, Original-Port = (\S+), Flapping port = (\S+)\.')

ports=set()

with open(r'c:\tools\log.txt') as f:
	for line in f:
		#print(line.strip())
		match=re.search(regex,line)
		if match:
			vlan=match.group(1)
			ports.add(match.group(2))
			ports.add(match.group(3))

print('Loop between ports {}in VLAN {}'.format(', '.join(ports),vlan))
